package com.LeeCode;

/**
 * 回文数
 */

public class Code009 {

    public int reverse(int x) {

        int res = 0;
        while (x != 0) {
            if (res < Integer.MIN_VALUE / 10 || res > Integer.MAX_VALUE / 10) {
                return 0;
            }
            res = res * 10 + x % 10;
            x /= 10;
        }
        return res;
    }

    public boolean isPalindrome(int x) {
        if (x < 0)
            return false;
        else {
            int rev = reverse(x);
            if (rev == x)
                return true;
            else
                return false;
        }
    }
}
